package com.example.service;

import com.example.entity.College;
import com.example.entity.MbtiQuestion;
import com.example.mapper.MbtiQuestionMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MbtiQuestionService {

    @Resource
    private MbtiQuestionMapper mbtiQuestionMapper;
    public List<MbtiQuestion> getAllQuestions() {
        return mbtiQuestionMapper.findAll();
    }

    public PageInfo<MbtiQuestion> selectPage(MbtiQuestion mbtiQuestion, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<MbtiQuestion> list = mbtiQuestionMapper.selectPage(mbtiQuestion);
        return PageInfo.of(list);
    }

    public void add(MbtiQuestion mbtiQuestion) {
        mbtiQuestionMapper.add(mbtiQuestion);
    }

    public void update(MbtiQuestion mbtiQuestion) {
        mbtiQuestionMapper.update(mbtiQuestion);
    }

    public void delete(Integer questionId) {
        mbtiQuestionMapper.delete(questionId);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer questionId : ids){
            mbtiQuestionMapper.delete(questionId);
        }
    }
}
